package com.analysis.library.server1.controller;

import java.util.Random;

import org.springframework.beans.factory.annotation.Value;

import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RefreshScope
@RestController
@RequestMapping("/server")
public class ConfigController {

	@Value("${server.port}")
	private String serverport;

	@RequestMapping("/get")
	public String get() {
		return serverport;
	}
	
	@GetMapping("/getServer/{serverName}")
	public String getServer(@PathVariable("serverName") String serverName) {
		String result = "我是服务提供者002，我被getServer服务" + serverName + "调用了！";
		
		int[] data1 = new int[10];
		int max = -30;
		int min = -100;
		Random r = new Random();
		for(int i=0;i<data1.length;i++) {
			int randNumber =r.nextInt(max - min + 1) + min;
			data1[i]=randNumber;
		}
		
		
		
		
		return result;
	}
	
	
	
	public static void main(String[] args) {
		int[] data1 = new int[10];
		int max = -30;
		int min = -100;
		Random r = new Random();
		for(int i=0;i<data1.length;i++) {
			int randNumber =r.nextInt(max - min + 1) + min;
			data1[i]=randNumber;
			System.out.println(randNumber);
		}
	}
	
	
}
